﻿#ifndef FRMMAIN_H
#define FRMMAIN_H

#include <QtGui>
#if (QT_VERSION > QT_VERSION_CHECK(5,0,0))
#include <QtWidgets>
#endif

#include "IPCDef.h"
#include <vector>
#include "IPC_Manager.h"
#include "VideoPlayItemWidget.h"

namespace Ui
{
class frmMain;
}

class frmMain : public QWidget
{
    Q_OBJECT

public:
    explicit frmMain(IPCManager* mgr,QWidget *parent = 0);
    ~frmMain();
	//QVector<QLabel *> widgets;
	QVector<VideoPlayItemWidget *> widgets;
	
	QVector<WId> widget_wids;
protected:
    bool eventFilter(QObject *watched, QEvent *event);

private:
    Ui::frmMain *ui;

    bool videoMax;
    int videoCount;
    QString videoType;
    QMenu *videoMenu;
   

public slots:
	void onChangedViewGridMode(QString mode);

private slots:
    void initForm();
    void initMenu();

private slots:
    void play_video_all();
	//void start_video_all();
    void snapshot_video_one();
    void snapshot_video_all();

    void show_video_all();
    void show_video_4();
    void show_video_6();
    void show_video_8();
    void show_video_9();
    void show_video_16();
    void show_video_36();

    void hide_video_all();
    void change_video(int index, int flag);
    void change_video_4(int index);
    void change_video_6(int index);
    void change_video_8(int index);
    void change_video_9(int index);
    void change_video_16(int index);
    void change_video_36(int index);
private slots:
	void onVideo_start_play(int widget_index);
	void onVideo_stop_play(int widget_index);
	void onIPC_logionStatus(int status, QString uniqueKey);


private:
	void onMouseButtonPress_VIDEO(VideoPlayItemWidget *widget, QMouseEvent *mouseEvent);
	void onMouseButtonRelease_VIDEO(VideoPlayItemWidget *widget, QMouseEvent *mouseEvent);
	void onMouseMove_VIDEO(VideoPlayItemWidget *widget , QMouseEvent *mouseEvent);
	void onWheel_VIDEO(VideoPlayItemWidget *widget, QWheelEvent *wheelEvent);
	void onMouseButtonDblClick_VIDEO(VideoPlayItemWidget *widget, QMouseEvent *wheelEvent);


private:
	std::vector<IPC_Dev_Object_t>	IPC_Dev_Object_Vec;
	IPCManager* ipc_mgr;
	QMap<QString, QAction*> videoMenuActionMap;

	bool isLBPressed; //左键是否被按下
	QPoint LBPressdPoint; //左键按下的位置
	QMap<DWORD, QCursor>	IPCMoveCursor;
	bool isRBPressed; //右键是否被按下
	QPoint RBPressedPoint;//右键按下的位置

};

#endif // FRMMAIN_H
